package hu.szte.ovrt.mzst;

import java.util.ArrayList;
import hu.szte.ovrt.mzst.exceptions.BadOperandException;
import hu.szte.ovrt.mzst.interfaces.Expression;
import hu.szte.ovrt.mzst.operations.Copy;
import hu.szte.ovrt.mzst.operations.CreateDirectory;
import hu.szte.ovrt.mzst.operations.CreateFile;
import hu.szte.ovrt.mzst.operations.DeleteDirectory;
import hu.szte.ovrt.mzst.operations.DeleteFile;
import hu.szte.ovrt.mzst.operations.Move;
import hu.szte.ovrt.visitors.ExpressionVisitor;

public class Block implements Expression {
	
	private Block parentBlock;
	private ArrayList<Expression> expressions;
	
	public Block(Block parentBlock) {
		super();
		this.parentBlock = parentBlock;
		
		this.expressions = new ArrayList<Expression>();
	}

	public Block getParentBlock() {
		return parentBlock;
	}

	public void setParentBlock(Block parentBlock) {
		this.parentBlock = parentBlock;
	}
	
	public void addExpression(Expression expression){
		expressions.add(expression);
	}
	
	

//	@Override
//	public void execute() throws BadOperandException {
//		for (Expression executable : expressions) {
//			executable.execute();
//		}
//	}

	public ArrayList<Expression> getExpressions() {
		return expressions;
	}

	@Override
	public void interpret() throws BadOperandException {
		for (Expression expression : expressions) {
			expression.interpret();
		}
	}

	@Override
	public void accept(ExpressionVisitor visitor) {
		for (Expression expression : expressions) {
			expression.accept(visitor);
		}
	}

}
